/* 复制对象 */
function clone (item) {
    if(!item){return item;} // null, undefined values check  
    var types = [Number,String,Boolean],
    result;

    types.forEach(function(type){
        if(item instanceof type){
            result = type(item);
        }
    });

    if(typeof result == "undefined"){
        if(Object.prototype.toString.call(item) === "[object Array]"){
            result = [];
            item.forEach(function(child,index,array){
                result[index] = clone(child);
            });
        }else if(typeof item == "object"){
            if(item.nodeType && typeof item.cloneNode == "function"){
                var result = item.cloneNode(true);
            }else if(!item.protoype){
                result = {};
                for(var i in item){
                    result[i] = clone(item[i]);
                }
            }else{
                // 这里解决的是带钩子函数的情况,深的话,去掉那个false &&,浅的,维持原有的引用
                if(false && item.constructor){
                    result  = new item.constructor();
                }else{
                    result = item;
                }
            }
        }else{
            result = item;
        }
    }
    return result;
}